Mortgage Demo Example¶
[1]:
from cuXfilter import charts
import cuXfilter
from bokeh import palettes
from cuXfilter.layouts import layout_1
import warnings
warnings.filterwarnings('ignore')
Load cuXfilter dataframe¶
[2]:
cux_df = cuXfilter.DataFrame.from_arrow('/home/ajay/data/146M_predictions_v2.arrow')
Define Charts¶
[3]:
chart0 = charts.bokeh.choropleth(x='zip', y='delinquency_12_prediction', aggregate_fn='mean',
geo_color_palette=palettes.Inferno256,
geoJSONSource = 'https://raw.githubusercontent.com/rapidsai/cuxfilter/master/javascript/demos/GTC%20demo/src/data/zip3-ms-rhs-lessprops.json',
data_points=1000, width=1100, x_range=(-126, -66), y_range=(23, 50))
chart2 = charts.bokeh.bar('delinquency_12_prediction',data_points=50, width=400, height=400)
chart3 = charts.panel_widgets.range_slider('borrower_credit_score',data_points=50,width=400, height=400)
Add mappings for chart1¶
[4]:
mapper1 = {}
for val in cux_df.data.dti.unique().to_pandas().tolist():
mapper1[int(val)] = 'l_'+str(val)
chart1 = charts.panel_widgets.multi_select('dti', width=400, height=400, label_map=mapper1)
#also available: panel_widgets.dropdown
Create dashboard¶
[5]:
d = cux_df.dashboard([chart0, chart1], layout=layout_1, title="Ajay's Dashboard")
[6]:
#add more charts
d.add_charts([chart2, chart3])
[7]:
# d.show('url you want the dashboard to run') remote dashboard:
# d.app('10.110.47.43:8888') within the notebook: If you are using jupyter remotely, use this line instead of second, and replace url with current notebook url
#d.app() for local interactive behavior
#d.preview() for just a view of the dashboard, interaciton not available. Recommended way to generate when uploading to git remote site
await d.preview()
Export the queried data into a dataframe¶
[8]:
queried_df = d.export()
no querying done, returning original dataframe